package com.gitee.sop.order.service.impl;

import com.gitee.sop.order.dto.OrderFormDto;
import com.gitee.sop.order.service.OrderFormService;

/**
 * @author: Admin
 * @date: 2021/3/24
 * @description:
 * @copyright: 重庆万蓝兴科技有限公司
 */
public class OrderFormServiceImpl implements OrderFormService {

    public String createOrder(OrderFormDto query) {
        String appId = query.getAppId();
        Integer bizType = query.getBizType();
        Integer payment = query.getPayment();
        String payDescription = query.getPayDescription();
        //@TODO 预留开放平台购买某种功能等需要创建对应的订单
        return null;
    }

//    @Override
//    @Transactional(rollbackFor = InterruptedException.class)
//    public Object getSign(String orderCode, int payType) throws AlipayApiException {
//        //1 根据订单号获取订单，判断订单状态
//        LambdaQueryWrapper<OrderForm> wrapper = new QueryWrapper<OrderForm>().lambda();
//        wrapper.eq(OrderForm::getOrderNumber, orderCode);
//        OrderForm order = this.getOne(wrapper);
//
//        if (Objects.isNull(order)) {
//            return Result.fail("订单不存在");
//        }
//        if (!order.getPayStatus().equals(OrderContant.ORDER_PAY_WAIT)) {
//            return Result.fail("已支付");
//        }
//        //2 根据选择的支付方式，获取第三方签名
//        if (payType == OrderContant.ORDER_PAID_ALI) {
//            String[] arr;
//            arr = aliPayUtil.orderCreate(order);
//            //3 返回签名的内容
//            String sign = arr[0];
//            return Result.success(ObjectUtil.toMap("sign", sign));
//        } else if (payType == OrderContant.ORDER_PAID_WX) {
//            WeixinOrder weixinOrder = new WeixinOrder();
//            weixinOrder.setBody(order.getPayDescription());
//            weixinOrder.setOut_trade_no(order.getOrderNumber());
//            //只能是分
//            weixinOrder.setTotal_fee(order.getOrderPrice().multiply(new BigDecimal(100)).intValue());
//            Map<String, String> precreate = wxpayService.preCreate(weixinOrder);
//            return Result.success(precreate);
//        }
//        return Result.fail("订单不存在");
//    }

}
